package com.appkubes.mall.admin.application.user.user.controller;

import com.appkubes.cloud.config.params.paramValid.ParamValid;
import com.appkubes.common.Response;
import com.appkubes.mall.admin.application.user.user.entity.vo.UserUpdateVO;
import com.appkubes.mall.core.controller.BaseMallUserController;
import com.appkubes.mall.core.entity.MallUser;
import com.appkubes.mall.core.service.BaseMallUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: Rongjie
 * @Date: 2020/2/28
 * @Description:
 */
@Api(tags = "用户基础模块")
@RequestMapping("/user")
@RestController
public class UserController extends BaseMallUserController {
    @Resource
    BaseMallUserService baseMallUserService;

    @ApiOperation("更新用户基础资料")
    @PostMapping("/update")
    public Response update(@ParamValid UserUpdateVO userUpdateVO) {
        MallUser user = baseMallUserService.getById(userUpdateVO.getUserKey());
        Boolean flag = false;
        if (user != null) {
            BeanUtils.copyProperties(userUpdateVO, user);
            flag = baseMallUserService.updateById(user);
        }
        return Response.success(flag);
    }

}
